package com.example.permission.myjbm.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.jbmsuppliers.R;
import com.example.permission.myjbm.dao.BaseAdapter;
import com.jbm.jbmsupplier.util.PointsEntity;

import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Locale;

/**
 *
 * 积分中心的明细
 * Created by JBMhaier on 2017/3/15.
 */

public class IntegralListAdapter extends BaseAdapter{
    private final SimpleDateFormat formate;
    private List<PointsEntity> arr;
    public IntegralListAdapter(List<PointsEntity> arr, Context c) {
        super(c);
        formate=new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
        this.arr=arr;
    }

    @Override
    protected Object getHolder(View convertView) {
        return new myHolder(convertView);
    }

    @Override
    protected int getLayout() {
        return R.layout.dsy_item_integral_lv;
    }

    @Override
    protected Object getArr() {
        return arr;
    }

    @Override
    protected void initView(Object holder, int position) {
        ((myHolder)holder).jifen.setText(arr.get(position).getAmount()>0?"+"+arr.get(position).getAmount(): arr.get(position).getAmount()+"");
        ((myHolder)holder).title.setText( arr.get(position).getRuleEntity()==null?"": arr.get(position).getRuleEntity().getMemo());
        ((myHolder)holder).date.setText(formate.format(arr.get(position).getCreateDate()));
    }

    @Override
    protected void initListener(Object holder, int position) {

    }
   static class myHolder{
       private final TextView jifen,date,title;

       public myHolder(View convertView){
           jifen=(TextView)convertView.findViewById(R.id.mingxi_jifen);
           title=(TextView)convertView.findViewById(R.id.mingxi_title);
           date=(TextView)convertView.findViewById(R.id.mingxi_date);
       }


    }

}
